#ifndef __RWLOCK_H__
#define __RWLOCK_H__
#include "zemb/BaseType.h"
class RWLock {
DECL_CLASSNAME(RWLock)
public:
    RWLock(){};
    ~RWLock(){};
    RWLock(const RWLock &rw):m_cnt(rw.m_cnt){}
public:
    void lockR();
    int tryLockR();
    void unLockR();
    int tryLockW();
    void lockW();
    void unLockW();

private:
    volatile int m_cnt{0}; /**< -1 when W lock held, > 0 when R locks held. */
};

#endif